package com.qf.dao.impl;

import com.qf.dao.GoodsTypeDao;
import com.qf.model.GoodsType;
import com.qf.util.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.Connection;
import java.util.List;

public class GoodsTypeDaoImpl implements GoodsTypeDao {

    QueryRunner qr=new QueryRunner();
    @Override
    public List<GoodsType> selectGoodsTypes() {
        Connection con=null;
        List<GoodsType> query=null;
        try {
            con= JDBCUtil.getCon();
            String sql="select * from type";
            query = qr.query(con, sql, new BeanListHandler<GoodsType>(GoodsType.class));
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            JDBCUtil.colseCon(con);
        }
        return query;
    }
}
